Skip to content

Instantly share code, notes, and snippets.

@syncom
Last active April 21, 2018 19:42
Show Gist options
  • Save syncom/8387397a9021a547f5a7fd548c123e93 to your computer and use it in GitHub Desktop.
Save syncom/8387397a9021a547f5a7fd548c123e93 to your computer and use it in GitHub Desktop.
Build SEAL library using Clang with Static Analyzer on Ubuntu Linux

This short memo gives instructions on how to build the Microsoft Research's Simple Encrypted Arithmetic Library (SEAL) using LLVM/Clang, and also with the Clang Static Analyzer for software quality/security assurance.

The SEAL Library

The SEAL Library can be downloaded at its website http://sealcrypto.org (it redirects to a Microsoft page). The version of SEAL we use for this demonstration is SEAL_v2.3.0-4_Linux.tar.gz (available at https://www.microsoft.com/en-us/download/details.aspx?id=56202).

Installation of Clang/LLVM on Ubuntu 16.04

For support of C++ 11, we need Clang 3.3 and above. As of April 2018, The current default version of Clang on Ubuntu 16.04 is clang-3.8. Install with aptitude:

sudo aptitude install clang

It installed clang to /usr/bin/clang, which is a symbolic link to /usr/lib/llvm-3.8/bin/clang.

Build SEAL using Clang

  1. First decompress the tarball, and change to the source directory:

    tar xvfz SEAL_v2.3.0-4_Linux.tar.gz
    cd SEAL/SEAL
    
  2. Run the ./configure command to generate the build scripts:

    ./configure
    
  3. Make a copy of the generated Makefile:

    cp Makefile Makefile.clang
    
  4. Open Makefile.clang for edit. Replace the line CXX=g++ with CXX=clang++.

  5. Open seal/util/defines.h for edit. Comment out (or delete) the following lines:

    // GNU GCC/G++
    #if defined(__GNUC__) && (__GNUC__ < 5)
    #error "SEAL requires __GNUC__ >= 5" 
    #endif
    
  6. Build using clang with the static analyzer

    scan-build make -f Makefile.clang
    
  7. Inspect the Clang static analyzer generated report for potential bugs. One may use the scan-view tool or just open the index.html file with a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment