1

(6 replies, posted in wolfSSL)

Dear Kaleb,

thanks for the update. I will try to reproduce the steps. However, I should mention that I am working with TI Stellaris Launchpad (LM4F120H5QR), which is the predecessor of Tiva-C. TI doesn't support this platform anymore.

Also sorry for the late reply. I wasn't subscribed to this thread and thus didn't get any mail notification. I stalled working an this process due to other projects. I will let you know once I tried it.

Best,
André

Hi everyone,

I want to get wolfSSL working in combination with TI-RTOS on Ubuntu 15.10.

I downloaded TI-RTOS for TivaC from [1] and installed it to /opt/ti. Next, I cloned wolfSSL from Github [2], I uncommented

#define WOLFSSL_TIRTOS

and modified products.mak in {wolfssl_root}/tirtos to have the following content:

#
#  ======== products.mak ========
#
#
# Read the http://processors.wiki.ti.com/index.php/Using_wolfSSL_with_TI-RTOS
# for instructions to download the software required.

# XDC_INSTALL_DIR is the path to XDCtools directory.
XDC_INSTALL_DIR        = /opt/ti/xdctools_3_31_01_33_core

# BIOS_INSTALL_DIR is the path to TI-RTOS Kernel (SYS/BIOS) directory. If you
# have installed TI-RTOS, it is located in the products/bios_* path.
BIOS_INSTALL_DIR       = /opt/ti/tirtos_tivac_2_14_04_31/products/bios_6_42_03_35

# NDK_INSTALL_DIR is the path to TI-RTOS NDK directory. If you have
# installed TI-RTOS, it is located in the products/ndk_* path.
NDK_INSTALL_DIR        = /opt/ti/tirtos_tivac_2_14_04_31/products/ndk_2_24_03_35

# TIVAWARE_INSTALL_DIR is the path to Tivaware driverlib directory. If you have
# installed TI-RTOS, it is located in the products/TivaWare_* path.
TIVAWARE_INSTALL_DIR   = /opt/ti/tirtos_tivac_2_14_04_31/products/TivaWare_C_Series-2.1.1.71b

# Define the code generation tools path for TI, IAR and GCC ARM compilers.
# If you have installed Code Composer Studio, the TI and GCC compiler are
# located in the ccsv*/tools/compiler/* path.
#
# Leave assignment empty to disable any toolchain.
ti.targets.arm.elf.M4F =
iar.targets.arm.M4F    =
gnu.targets.arm.M4F    =

Next, I issued the following commands in {wolfssl_root}:

$ ./configure --prefix=/opt/wolf/ --enable-aesgcm --enable-aesccm
$ make

I get the following errors:

make -j5  all-am
make[1]: Entering directory '/home/andre/tmp/wolfssl-git/wolfssl-master'
  CC       wolfcrypt/src/src_libwolfssl_la-hash.lo
  CC       wolfcrypt/src/src_libwolfssl_la-random.lo
  CC       wolfcrypt/src/src_libwolfssl_la-rsa.lo
  CC       wolfcrypt/src/src_libwolfssl_la-hmac.lo
  CC       wolfcrypt/src/src_libwolfssl_la-sha256.lo
In file included from wolfcrypt/src/hash.c:26:0:
./wolfssl/wolfcrypt/settings.h:470:0: warning: "USE_FAST_MATH" redefined
     #define USE_FAST_MATH
 ^
In file included from wolfcrypt/src/random.c:26:0:
./wolfssl/wolfcrypt/settings.h:470:0: warning: "USE_FAST_MATH" redefined
     #define USE_FAST_MATH
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/random.c:26:0:
./wolfssl/wolfcrypt/settings.h:477:0: warning: "HAVE_ECC" redefined
     #define HAVE_ECC
 ^
<command-line>:0:0: note: this is the location of the previous definition
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/random.c:26:0:
./wolfssl/wolfcrypt/settings.h:486:40: fatal error: ti/sysbios/hal/Seconds.h: No such file or directory
compilation terminated.
In file included from wolfcrypt/src/hash.c:26:0:
./wolfssl/wolfcrypt/settings.h:477:0: warning: "HAVE_ECC" redefined
     #define HAVE_ECC
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/hash.c:26:0:
./wolfssl/wolfcrypt/settings.h:486:40: fatal error: ti/sysbios/hal/Seconds.h: No such file or directory
compilation terminated.
In file included from wolfcrypt/src/rsa.c:26:0:
./wolfssl/wolfcrypt/settings.h:470:0: warning: "USE_FAST_MATH" redefined
     #define USE_FAST_MATH
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/rsa.c:26:0:
./wolfssl/wolfcrypt/settings.h:477:0: warning: "HAVE_ECC" redefined
     #define HAVE_ECC
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/rsa.c:26:0:
./wolfssl/wolfcrypt/settings.h:486:40: fatal error: ti/sysbios/hal/Seconds.h: No such file or directory
compilation terminated.
Makefile:2449: recipe for target 'wolfcrypt/src/src_libwolfssl_la-rsa.lo' failed
make[1]: *** [wolfcrypt/src/src_libwolfssl_la-rsa.lo] Error 1
make[1]: *** Auf noch nicht beendete Prozesse wird gewartet …
Makefile:2435: recipe for target 'wolfcrypt/src/src_libwolfssl_la-hash.lo' failed
make[1]: *** [wolfcrypt/src/src_libwolfssl_la-hash.lo] Error 1
Makefile:2421: recipe for target 'wolfcrypt/src/src_libwolfssl_la-random.lo' failed
make[1]: *** [wolfcrypt/src/src_libwolfssl_la-random.lo] Error 1
In file included from wolfcrypt/src/hmac.c:26:0:
./wolfssl/wolfcrypt/settings.h:470:0: warning: "USE_FAST_MATH" redefined
     #define USE_FAST_MATH
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/hmac.c:26:0:
./wolfssl/wolfcrypt/settings.h:477:0: warning: "HAVE_ECC" redefined
     #define HAVE_ECC
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/hmac.c:26:0:
./wolfssl/wolfcrypt/settings.h:486:40: fatal error: ti/sysbios/hal/Seconds.h: No such file or directory
compilation terminated.
Makefile:2414: recipe for target 'wolfcrypt/src/src_libwolfssl_la-hmac.lo' failed
make[1]: *** [wolfcrypt/src/src_libwolfssl_la-hmac.lo] Error 1
In file included from wolfcrypt/src/sha256.c:28:0:
./wolfssl/wolfcrypt/settings.h:470:0: warning: "USE_FAST_MATH" redefined
     #define USE_FAST_MATH
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/sha256.c:28:0:
./wolfssl/wolfcrypt/settings.h:477:0: warning: "HAVE_ECC" redefined
     #define HAVE_ECC
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from wolfcrypt/src/sha256.c:28:0:
./wolfssl/wolfcrypt/settings.h:486:40: fatal error: ti/sysbios/hal/Seconds.h: No such file or directory
compilation terminated.
Makefile:2428: recipe for target 'wolfcrypt/src/src_libwolfssl_la-sha256.lo' failed
make[1]: *** [wolfcrypt/src/src_libwolfssl_la-sha256.lo] Error 1
make[1]: Leaving directory '/home/andre/tmp/wolfssl-git/wolfssl-master'
Makefile:1652: recipe for target 'all' failed
make: *** [all] Error 2

What is going wrong? bias, ndk, TIvaWare and UIA exist:

ls -l /opt/ti/tirtos_tivac_2_14_04_31/products/
insgesamt 16
drwxrwxr-x  5 root root 4096 Jan 27 15:35 bios_6_42_03_35
drwxrwxr-x  6 root root 4096 Jan 27 15:35 ndk_2_24_03_35
drwxrwxrwx 13 root root 4096 Jan 27 15:34 TivaWare_C_Series-2.1.1.71b
drwxrwxr-x  7 root root 4096 Jan 27 15:35 uia_2_00_02_39

Also, there seems to be Seconds.h:

find /opt/ti/ -iname 'seconds.h'
./tirtos_tivac_2_14_04_31/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/cc26xx/Seconds.h
./tirtos_tivac_2_14_04_31/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/cc32xx/Seconds.h
./tirtos_tivac_2_14_04_31/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/lm4/Seconds.h
./tirtos_tivac_2_14_04_31/products/bios_6_42_03_35/packages/ti/sysbios/hal/Seconds.h

[1] - http://software-dl.ti.com/dsps/dsps_pub … _04_31.bin
[2] - https://github.com/wolfSSL

Hi,

I want to implement AES-GCM and have the following questions:

1. looking at the implementation of

wc_AesGcmDecrypt

in wolfcrypt/src/aes.c the code calls

AesGcmDecrypt_fips

. However, if I grep for

AesGcmDecrypt_fips

in the wolfSSL folder, I get no other result beside the

wc_AesGcmDecrypt

implementation. Where is

AesGcmDecrypt_fips

implemented?

2. In the code below,

wc_AesGcmDecrypt

returns -180. What does this mean?

#include <wolfssl/wolfcrypt/aes.h>
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "inttypes.h"

void printhex(unsigned char myarray[], unsigned int size);

//__aead(byte plaintext[], byte iv[], byte addAuthData[])
unsigned long main()
{

      int  result;
    Aes enc;

    printf("Entering aead() function...\n");

    // additional plaintext that is to be authenticated
    // with the plaintext being encrypted
    const byte addAuthData[] =
    {
        0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
        0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
        0xab, 0xad, 0xda, 0xd2
    };

    const byte key[] =
    {
        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
        0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c
    };

    const byte iv[] =
    {
        0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
        0xde, 0xca, 0xf8, 0x88
    };

    const byte plaintext[] =
    {
        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
        0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c
    };

    byte plaintextresult[sizeof(plaintext)];
    byte authTag[32];
    byte ciphertext[32];

    //    set key for AES-GCM
    //    wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
    wc_AesGcmSetKey(&enc, key, sizeof(key));

    printf("\nSetting key for aead() operation:\n");
    printhex(key, sizeof(key));
    //    perform encryption
    /*
    wc_AesGcmEncrypt(Aes* aes, byte* out,
                     const byte* in, word32 sz,
                     const byte* iv, word32 ivSz,
                     byte* authTag, word32 authTagSz,
                     const byte* authIn, word32 authInSz);
    */
    wc_AesGcmEncrypt(&enc, ciphertext,
                    plaintext, sizeof(plaintext),
                    iv, sizeof(iv), 
                    authTag, sizeof(authTag),
                    addAuthData, sizeof(addAuthData));
    printf("\nEncrypting plaintext:\n");
    printhex(plaintext, sizeof(plaintext));
    printf("\nCipher:\n");
    printhex(ciphertext, sizeof(ciphertext));

    //    perform decryption
    /*
    wc_AesGcmDecrypt(Aes* aes, byte* out,
                    const byte* in, word32 sz,
                    const byte* iv, word32 ivSz,
                    const byte* authTag, word32 authTagSz,
                    const byte* authIn, word32 authInSz);
    */
    result = wc_AesGcmDecrypt(&enc, plaintextresult,
                    ciphertext, sizeof(ciphertext),
                    iv, sizeof(iv),
                    authTag, sizeof(authTag),
                    addAuthData, sizeof(addAuthData));

    printf("\nDecrypting ciphertext (result: %d)\n", result);
    printhex(plaintextresult, sizeof(plaintextresult));
    //printf();


      return (0);
}

4

(1 replies, posted in wolfCrypt)

Dear all,

amongst other crypto blocks (HMAC-SHA256) I want to use AES-GCM in my code. In particular, I want to use wc_AesGcmSetKey(), wc_AesGcmEncrypt() and wc_AesGcmDecrypt(). For test purposes I created the file aead.c with the following content:

#include <wolfssl/wolfcrypt/aes.h>
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "inttypes.h"

...
...

unsigned long __aead(void);

unsigned long __aead()
{
      int  result;
    Aes enc;

    // additional plaintext that is to be authenticated
    // with the plaintext being encrypted
    const byte addAuthData[] =
    {
        0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
        0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
        0xab, 0xad, 0xda, 0xd2
    };

    const byte key[] =
    {
        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
        0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c
    };

    const byte iv[] =
    {
        0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
        0xde, 0xca, 0xf8, 0x88
    };

    const byte plaintext[] =
    {
        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
        0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
        0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c
    };

    byte plaintextresult[sizeof(plaintext)];
    byte authTag[32];
    byte ciphertext[32];

    //    set key for AES-GCM
    //    wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
    wc_AesGcmSetKey(&enc, key, sizeof(key));


    //    perform encryption
    /*
    wc_AesGcmEncrypt(Aes* aes, byte* out,
                     const byte* in, word32 sz,
                     const byte* iv, word32 ivSz,
                     byte* authTag, word32 authTagSz,
                     const byte* authIn, word32 authInSz);
    */
    wc_AesGcmEncrypt(&enc, ciphertext,
                    plaintext, sizeof(plaintext),
                    iv, sizeof(iv), 
                    authTag, sizeof(authTag),
                    addAuthData, sizeof(addAuthData));

    //    perform decryption
    /*
    wc_AesGcmDecrypt(Aes* aes, byte* out,
                    const byte* in, word32 sz,
                    const byte* iv, word32 ivSz,
                    const byte* authTag, word32 authTagSz,
                    const byte* authIn, word32 authInSz);
    */
    result = wc_AesGcmDecrypt(&enc, plaintextresult,
                    ciphertext, sizeof(ciphertext),
                    iv, sizeof(iv),
                    authTag, sizeof(authTag),
                    addAuthData, sizeof(addAuthData));

    c_stop = HWREG(DWT_BASE + DWT_O_CYCCNT);

}

My Makefile looks like this:

PART=LM4F120H5QR
VARIANT=cm4f
ROOT=../../..
include ${ROOT}/makedefs
VPATH=../../../third_party/FreeRTOS/Source/portable/GCC/ARM_CM4F
VPATH+=../../../third_party/FreeRTOS/Source/portable/MemMang/
VPATH+=../../../third_party/FreeRTOS/Source
VPATH+=../drivers
VPATH+=../../../utils
VPATH+=../../../utils
VPATH+=wolfcrypt/src/
VPATH+=wolfss/wolfcrypt/
IPATH=.
IPATH+=..
IPATH+=../../..
IPATH+=../../../third_party/FreeRTOS/Source/portable/GCC/ARM_CM4F
IPATH+=../../../third_party/FreeRTOS
IPATH+=../../../third_party/FreeRTOS/Source/include
IPATH+=../../../third_party

all: ${COMPILER}
all: ${COMPILER}/attest_freertos.axf

clean:
    @rm -rf ${COMPILER} ${wildcard *~}


${COMPILER}:
    @mkdir -p ${COMPILER}

${COMPILER}/attest_freertos.axf: ${COMPILER}/aead.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/aes.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/attest_freertos.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/buttons.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/heap_2.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/enableTiming.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/hmac.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/led_task.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/lets_hash.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/list.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/printhex.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/port.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/queue.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/rgb.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/set_key.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/sha256.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/startup_${COMPILER}.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/startup_flash.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/switch_task.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/tasks.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/uartstdio.o
${COMPILER}/attest_freertos.axf: ${COMPILER}/ustdlib.o
${COMPILER}/attest_freertos.axf: ${ROOT}/driverlib/${COMPILER}-cm4f/libdriver-cm4f.a
${COMPILER}/attest_freertos.axf: attest_freertos.ld
SCATTERgcc_attest_freertos=attest_freertos.ld
ENTRY_attest_freertos=ResetISR
CFLAGSgcc=-DTARGET_IS_BLIZZARD_RA1

ifneq (${MAKECMDGOALS},clean)
-include ${wildcard ${COMPILER}/*.d} __dummy__
endif

Trying to compile the *axf file using make, the following errors pop up:

CC    aead.c
In file included from ./wolfssl/wolfcrypt/types.h:27:0,
                 from ./wolfssl/wolfcrypt/aes.h:25,
                 from aead.c:1:
./wolfssl/wolfcrypt/wc_port.h:104:33: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wolfSSL_Mutex'
./wolfssl/wolfcrypt/wc_port.h:167:42: error: expected ')' before '*' token
./wolfssl/wolfcrypt/wc_port.h:168:42: error: expected ')' before '*' token
./wolfssl/wolfcrypt/wc_port.h:169:42: error: expected ')' before '*' token
./wolfssl/wolfcrypt/wc_port.h:170:44: error: expected ')' before '*' token
aead.c: In function '__aead':
aead.c:73:2: warning: implicit declaration of function 'wc_AesGcmSetKey'
aead.c:84:2: warning: implicit declaration of function 'wc_AesGcmEncrypt'
aead.c:98:2: warning: implicit declaration of function 'wc_AesGcmDecrypt'
../../../makedefs:189: recipe for target 'gcc/aead.o' failed
make: *** [gcc/aead.o] Error 1

This is strange as I was able to successfully use other crypto primitives (SHA-1, HMAC) this way.

What am I missing?

Best regards.