<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[wolfSSL - Embedded SSL Library — AES-GCM compilation problem]]></title>
		<link>https://www.wolfssl.com/forums/topic755-aesgcm-compilation-problem.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic755.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in AES-GCM compilation problem.]]></description>
		<lastBuildDate>Wed, 13 Jan 2016 00:12:08 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AES-GCM compilation problem]]></title>
			<link>https://www.wolfssl.com/forums/post2378.html#p2378</link>
			<description><![CDATA[<p>Hi,</p><p>It looks like you need a couple extra defines when compiling wolfSSL and your application, mainly:</p><p><strong>FREERTOS</strong> - this enables wolfSSL&#039;s FreeRTOS port layer<br /><strong>HAVE_AESGCM</strong> - this enables AES-GCM in wolfSSL</p><p>You&#039;ll need to compile both your application code and the wolfSSL library with the same preprocessor defines.&nbsp; To make this easier, if you define <strong>WOLFSSL_USER_SETTINGS</strong> when compiling wolfSSL, wolfSSL will expect to find a &lt;user_settings.h&gt; header file on the include path.&nbsp; You can put all your custom defines there, and also include it in your application code.</p><p>Do you mind if I ask what type of project you are working on?</p><p>Best Regards,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Wed, 13 Jan 2016 00:12:08 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2378.html#p2378</guid>
		</item>
		<item>
			<title><![CDATA[AES-GCM compilation problem]]></title>
			<link>https://www.wolfssl.com/forums/post2371.html#p2371</link>
			<description><![CDATA[<p>Dear all,</p><p>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:</p><div class="codebox"><pre><code>#include &lt;wolfssl/wolfcrypt/aes.h&gt;
#include &quot;stdio.h&quot;
#include &quot;string.h&quot;
#include &quot;stdlib.h&quot;
#include &quot;inttypes.h&quot;

...
...

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(&amp;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(&amp;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(&amp;enc, plaintextresult,
                    ciphertext, sizeof(ciphertext),
                    iv, sizeof(iv),
                    authTag, sizeof(authTag),
                    addAuthData, sizeof(addAuthData));

    c_stop = HWREG(DWT_BASE + DWT_O_CYCCNT);

}</code></pre></div><br /><p>My Makefile looks like this:</p><div class="codebox"><pre><code>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</code></pre></div><p>Trying to compile the *axf file using make, the following errors pop up:</p><div class="codebox"><pre><code>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 &#039;=&#039;, &#039;,&#039;, &#039;;&#039;, &#039;asm&#039; or &#039;__attribute__&#039; before &#039;wolfSSL_Mutex&#039;
./wolfssl/wolfcrypt/wc_port.h:167:42: error: expected &#039;)&#039; before &#039;*&#039; token
./wolfssl/wolfcrypt/wc_port.h:168:42: error: expected &#039;)&#039; before &#039;*&#039; token
./wolfssl/wolfcrypt/wc_port.h:169:42: error: expected &#039;)&#039; before &#039;*&#039; token
./wolfssl/wolfcrypt/wc_port.h:170:44: error: expected &#039;)&#039; before &#039;*&#039; token
aead.c: In function &#039;__aead&#039;:
aead.c:73:2: warning: implicit declaration of function &#039;wc_AesGcmSetKey&#039;
aead.c:84:2: warning: implicit declaration of function &#039;wc_AesGcmEncrypt&#039;
aead.c:98:2: warning: implicit declaration of function &#039;wc_AesGcmDecrypt&#039;
../../../makedefs:189: recipe for target &#039;gcc/aead.o&#039; failed
make: *** [gcc/aead.o] Error 1</code></pre></div><p>This is strange as I was able to successfully use other crypto primitives (SHA-1, HMAC) this way.</p><p>What am I missing?</p><p>Best regards.</p>]]></description>
			<author><![CDATA[null@example.com (an.schall)]]></author>
			<pubDate>Fri, 08 Jan 2016 16:21:16 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2371.html#p2371</guid>
		</item>
	</channel>
</rss>
