c++keccakpost-quantum-cryptography

C++ Using Keccak Library


Im working on my bachelor thesis and I have to test some post quantum algorithms. I downloaded them from NIST. But when I tried DAGS: https://csrc.nist.gov/CSRC/media/Projects/Post-Quantum-Cryptography/documents/round-1/submissions/DAGS.zip and tried to "make" dags3 or dags5 I got this error:

encapsulation.o: In function encapsulation': encapsulation.c:(.text+0xeb): undefined reference toKangarooTwelve' encapsulation.c:(.text+0x13a): undefined reference to KangarooTwelve' encapsulation.c:(.text+0x2c9): undefined reference toKangarooTwelve' encapsulation.c:(.text+0x478): undefined reference to KangarooTwelve' decapsulation.o: In functiondecapsulation': decapsulation.c:(.text+0x16e): undefined reference to KangarooTwelve' decapsulation.o:decapsulation.c:(.text+0x1bd): more undefined references toKangarooTwelve' follow collect2: error: ld returned 1 exit status Makefile:22: recipe for target 'PQCgenKAT_kem' failed make: *** [PQCgenKAT_kem] Error 1

I have keccak library installed and in this algorithm keccak library is included. Any ideas? Thank you for any help.


Solution

  • Pursuant to the comments, I had time to look into the build tonight (also on Archlinux), I didn't experience any problems. Here are the detailed steps I used.

    First the general kernel and gcc info:

    $ uname -a
    Linux valkyrie 4.19.4-arch1-1-ARCH #1 SMP PREEMPT 
    Fri Nov 23 09:06:58 UTC 2018 x86_64 GNU/Linux
    
    $ gcc --version
    gcc (GCC) 8.2.1 20180831
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

    Cloning the KeccakCodePackage:

    $ git clone https://github.com/gvanas/KeccakCodePackage
    

    I usually try and and do an out-of-source build, especially with git repos (just habit from building TDE/KDE3), so I just create a kbuild and copy the source files over:

    $ md kbuild
    $ cp -a KeccakCodePackage/* kbuild/
    $ cd kbuild
    

    Now build the required static library per the Readme file and copy the library and headers to /usr/local/, e.g.:

    $ make generic64/libkeccak.a
    
    $ sudo cp -a bin/generic64/libkeccak.a /usr/local/lib
    $ sudo cp -a bin/generic64/libkeccak.a.headers /usr/local/include
    

    Now unzip and build DAGS PQCgenKAT_kem

    $ cd ..
    $ unzip DAGS.zip
    $ cd DAGS/Optimized_Implementation/kem/dags5
    
    $ make
    gcc -c gf.c -o gf.o -march=native -mtune=native -c -Wall -I.
    gcc -c poly.c -o poly.o -march=native -mtune=native -c -Wall -I.
    gcc -c matrix.c -o matrix.o -march=native -mtune=native -c -Wall -I.
    matrix.c: In function ‘matrix_multiplication’:
    matrix.c:13:16: warning: ‘res’ may be used uninitialized in this function 
                    [-Wmaybe-uninitialized]
            return res;
                    ^~~
    matrix.c: In function ‘matrix_multiplicaion_subfield’:
    matrix.c:59:16: warning: ‘Res’ may be used uninitialized in this function 
                    [-Wmaybe-uninitialized]
            return Res;
                    ^~~
    gcc -c fichier.c -o fichier.o -march=native -mtune=native -c -Wall -I.
    gcc -c key_gen.c -o key_gen.o -march=native -mtune=native -c -Wall -I.
    gcc -c encapsulation.c -o encapsulation.o -march=native -mtune=native -c -Wall -I.
    gcc -c decapsulation.c -o decapsulation.o -march=native -mtune=native -c -Wall -I.
    gcc -c util.c -o util.o -march=native -mtune=native -c -Wall -I.
    gcc -c decoding.c -o decoding.o -march=native -mtune=native -c -Wall -I.
    gcc -c kem.c -o kem.o -march=native -mtune=native -c -Wall -I.
    gcc -c rng.c -o rng.o -march=native -mtune=native -c -Wall -I.
    gcc -c PQCgenKAT_kem.c -o PQCgenKAT_kem.o -march=native -mtune=native -c -Wall -I.
    gcc -O3 -march=native -mtune=native gf.o poly.o matrix.o fichier.o key_gen.o
        encapsulation.o decapsulation.o util.o decoding.o kem.o rng.o PQCgenKAT_kem.o 
        -o PQCgenKAT_kem -L/usr/lib -L. -lssl -lcrypto -lkeccak
    

    Finally run the resulting executable:

    $ ./PQCgenKAT_kem
    Starting iteration: 0
    

    (all good, no clue what it does from there, but no errors and it is started fine...)

    So, I'm not able to offer a "silver-bullet" of what went wrong with your build, but I can confirm the build, according to the various Readme files, proceeds as advertised and results in a working executable. Let me know if you have additional questions.