2012年9月14日 星期五

How-to-Build-CryptDB

Site:http://css.csail.mit.edu/cryptdb/

Indruction:(come from source site)

CryptDB

Online applications are vulnerable to theft of sensitive information because adversaries can exploit software bugs to gain access to private data, and because curious or malicious administrators may capture and leak data. CryptDB is a system that provides practical and provable confidentiality in the face of these attacks for applications backed by SQL databases. It works by executing SQL queries over encrypted data using a collection of efficient SQL-aware encryption schemes. CryptDB can also chain encryption keys to user passwords, so that a data item can be decrypted only by using the password of one of the users with access to that data. As a result, a database administrator never gets access to decrypted data, and even if all servers are compromised, an adversary cannot decrypt the data of any user who is not logged in. An analysis of a trace of 126 million SQL queries from a production MySQL server shows that CryptDB can support operations over encrypted data for 99.5% of the 128,840 columns seen in the trace. Our evaluation shows that CryptDB has low overhead, reducing throughput by 14.5% for phpBB, a web forum application, and by 26% for queries from TPC-C, compared to unmodified MySQL. Chaining encryption keys to user passwords requires 11-13 unique schema annotations to secure more than 20 sensitive fields and 2-7 lines of source code changes for three multi-user web applications.


Before install CryptDB on MySQL DB, First you need to make sure your system have following packet, my system is:

Intel:P4 3.0G
Ram :1GB
HD:160GB,5400rpm
OS:Ubuntu 11.10

Step 1 - Check system's packet on last version

open terminal windows(ctrl+alt+t), enter command in

sudo apt-get update
sudo apt-get upgrade

Step 2 - Install following packets

all packet need last version

1.  Bazaar
2.  Bison
3.  Gtk-doc
4.  Autoconf
5.  Automake
6.  Libtool
7.  Flex
8.  Gcc-4.6
9.  G++-4.6
10.Cmake
11. G++

and 

12 . apt-get install liblua5.1-0-dev libntl-dev libmysqlclient-dev \
                    libssl-dev libbsd-dev libevent-dev libglib2.0-dev 
13.  apt-get install \
       pkg-config \
       liblua5.1-0 \
       liblua5.1-dev \
       libevent-dev \
       libevent1  \
       libglib2.0-0 \
       libglib2.0-dev \
       libmysqlclient-dev \

Step 3 - download Program

CryptDB : git clone -b public git://g.csail.mit.edu/cryptdb

MySQL: wget http://es.csail.mit.edu/mysql-5.5.14.tar.gz 

MySQL-proxy: bzr branch lp:mysql-proxy

Step 4 : Start to Build CytptDB on MySQL

 - CytptDB on MySQL(not finish yet) -

※ tar zxf mysql-5.5.14.tar.gz

※ cp -R .../cryptdb/parser/mysql_mods/* mysql-5.5.14/
(you can use "ls -al" check file date if it's change)

rm mysql-5.5.14/sql/sql_yacc.{cc,h}

cd mysql-5.5.14

mkdir build

cd build

cmake -DWITH_EMBEDDED_SERVER=ON ..
(it will take few time)

make
(it will take few time)

Step 5 Build MySQL-Proxy

bzr branch lp:mysql-proxy

cd mysql-proxy

sh ./autogen.sh

./configure --enable-maintainer-mode --with-lua=lua5.1

make

make install

if you fails with error "g_debug_hexdump being undefined"

To Do

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


% patch -p0 <<"EOM"
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2010-10-28 11:58:51 +0000
+++ src/Makefile.am 2012-01-10 15:49:27 +0000
@@ -23,7 +23,7 @@

 BUILD_CPPFLAGS = $(LUA_CFLAGS) $(MYSQL_CFLAGS) $(GLIB_CFLAGS) $(GMODULE_CFLAGS) $(GTHREAD_CFLAGS)
 BUILD_CFLAGS   = -DLUAEXTDIR="\"$(luaextdir)\""  -DPLUGINDIR="\"$(plugindir)\""
-BUILD_LDADD    = $(GLIB_LIBS) $(GMODULE_LIBS) libmysql-chassis.la $(GTHREAD_LIBS) libmysql-proxy.la
+BUILD_LDADD    = $(GLIB_LIBS) $(GMODULE_LIBS) libmysql-chassis.la libmysql-chassis-glibext.la $(GTHREAD_LIBS) libmysql-proxy.la

 BUILT_SOURCES =
 if USE_WRAPPER_SCRIPT
EOM

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

Step 6 Install CryptDB


※ cd cryptdb/conf

※open config.mk.sample and change path for MYSRC (MYSRC is set to your mysql folder path) , then save as config.mk <--very important


※cd cryptdb

※make

※sudo make install


Now, you need to check  some ".so" file if it is success to generate

SEE cryptdb/obj folder



it's have six .so file

and then go to cryptdb/obj/udf

you will see edb.so, copy it to /usr/lib/mysql/plugin/


Now, you can see cryptdb/doc/README to run cryptdb

if you have any problem about install cryptdb, I will try to help as I can

30 則留言:

  1. Hi, I was trying to install in the said manner. I came across some issues that I couldn't resolve.

    1. after make in the 'mysql' installation, we don't have to do any 'make install'?
    2. during cryptdb install (step 6), 'sudo make install' is returning with "install: cannot create regular file '/usr/lib/mysql/plugin': No such file or directory' though I did everything the way it has been written here or in the doc/BUILD in cryptdb.

    Can you please help me with this?

    Regards,
    Sayantan Mukherjee

    回覆刪除
  2. Hi Sayantan Mukherjee
    About Q1, you need do "make install", but sorry, I really forget the reason

    Q2. you sure you install Mysql "server" and Mysql "client?"

    回覆刪除
  3. Hi, I am trying to compile the sources (step 6 make) . I have the following error :

    /home/peb/cryptdb-inst/CryptDB/crypto/prng.hh:98:13: error: ‘min’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
    In file included from /usr/include/c++/4.7/bits/char_traits.h:41:0,
    from /usr/include/c++/4.7/string:42,
    from /home/peb/cryptdb-inst/CryptDB/crypto/ope.hh:3,
    from crypto/ope.cc:2:
    /usr/include/c++/4.7/bits/stl_algobase.h:187:5: note: ‘template const _Tp& std::min(const _Tp&, const _Tp&)’ declared here, later in the translation unit

    Can you please help me ?

    Regards,

    PEB

    回覆刪除
  4. Hi. I'm having warnings while I'm performing the make command of building cryptdb on MySQL.
    The warnings state that: " dereferencing type-punned pointer will break strict-aliasing rule"

    Would that still be fine and will not cause future errors?

    回覆刪除
    回覆
    1. there's no need to worry; gcc tries to be more law obedient than the actual law.

      刪除
    2. I would like to consult you about the further installations problem that I may encounter.
      This is for my thesis requirement.
      Thanks a lot.

      刪除
    3. Can you post error message when you install cryptdb, because I'm not sure your system detail, you may face some problem that I never meet

      刪除
    4. I got this message when I entered make on installing cryptdb:
      "/home/ubuntu/cryptdb-inst/cryptdb/util/util.hh:93:19: fatal error: mysql.h: No such file or directory
      compilation terminated.
      make: *** [obj/crypto-old/OPE.o] Error 1"

      刪除
    5. //IF YOU ALREADY INSTALL MYSQL CLIENT//
      You need copy "mysql.h" to "~/cryptdb/util"
      try to find "mysql.h"

      //IF YOU ARE NOT INSTALL MYSQL CLIENT//
      You need install "MYSQL" client
      Use software center or download from MYSQL site
      after install mysql client
      find "mysql.h"

      刪除
    6. "http://es.csail.mit.edu/mysql-5.5.14.tar.gz "
      if you download from this link
      it's only have some libary the cryptdb will use
      so need download "MYSQL client" yourself
      /////////////////////////////////////////////
      some detail need user to find and install when you use
      ,and cryptdb's "README" not mention about it


      刪除
    7. I did what you just instructed me, then I came up with another problem. This time I do not know where to copy mysql.h file again

      In file included from /home/ubuntu/cryptdb-inst/cryptdb/edb/EDBProxy.hh:11:0,
      from edb/EDBProxy.cc:13:
      /home/ubuntu/cryptdb-inst/cryptdb/parser/embedmysql.hh:7:19: fatal error: mysql.h: No such file or directory
      compilation terminated.
      make: *** [obj/edb/EDBProxy.o] Error 1

      刪除
    8. 『sorry, I give you wrong answer, you need install mysql server, not mysql client, this is my fault』

      Install Mysql:http://askubuntu.com/questions/174138/how-to-install-mysql
      -------------------------------------------------------
      After install ,use "whereis" or "find" in terminal to find
      just like "whereis mysql.h" or "find mysql.h"
      then, use cp to copy file to target folder
      "cp [mysql.h file path][target folder]"




      刪除
    9. Okay. How will I resolve the previous error that I posted?
      I successfully transferred mysql.h and other .h files to cryptdb/util.
      I think the latest error wants me to move the same files to a new directory which is different to cryptdb/util.
      I cannot identify what directory it is. :(

      刪除
    10. Look like in folder "parser" need mysql.h
      the same, move mysql.h to target folder
      try to copy mysql.h to ~/cryptdb/parser

      刪除
    11. I just did your previous instruction to move the mysql.h file to cryptdb/parser
      Unfortunately, the error still exists. :(

      刪除
  5. Is there an Ubuntu .iso that already has this?

    回覆刪除
  6. Hi, thanks for your post! I managed to install CryptDB without errors. However,I have some problems to run it. I got the following errors when I try to run in a shell:
    main/Connect.cc:125 (execute): mysql_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT EXISTS cryptdbtest1' at line 1
    main/Connect.cc:126 (execute): on query: CREATE DATABASE IF NOT EXISTS cryptdbtest1;
    cdb_test: main/Connect.cc:105: static Connect* Connect::getEmbedded(const string&, const string&): Assertion `conn->execute("CREATE DATABASE IF NOT EXISTS " + dbname + ";")' failed.

    Do you have any ideas? Thanks

    回覆刪除
    回覆
    1. looks like you have SQL syntax error when you try to input
      1. first, make sure you already startup encrypt mode(follow the manul in crypt)
      2.if yes, check your SQL syntax
      >>CREATE DATABASE IF NOT EXISTS " + your_dbname + ";"

      刪除
  7. root@debian:/home/student# git clone -b public git://g.csail.mit.edu/cryptdb
    Cloning into 'cryptdb'...
    fatal: unable to connect to g.csail.mit.edu:
    g.csail.mit.edu[0: 128.30.44.149]: errno=Connection timed out


    What should i do to escape from this error??
    I have no Firewalls installed and no IPtables too.

    am using Debian 32 bit OS.

    回覆刪除
    回覆
    1. I try in Ubuntu 32-bit, it's work
      so I think it's Debian network setting cause it
      but I don't known how to solve it
      sorry...

      刪除
  8. I got the six *.so as you have mentioned. But i am unable to understand how to initiate the cryptdb, i read readme.txt, but am not getting it. Can you explain it precisely.

    回覆刪除
  9. root@student:/home/student/cryptdb/obj# ls
    crypto libedbcrypto.so libedbutil.so mysqlproxy test util
    libcryptdb.so libedbparser.so libexecute.so parser tools
    libedbcrypto.a libedbutil.a main scripts udf
    root@student:/home/student/cryptdb/obj#

    回覆刪除
  10. Hello,

    Thanks. I have installed the CryptDB and I could run QUERIES. My only issue is, its not using LIKE / ILIKE clause in the QUERY as defined by .../cryptdb/doc/demo_notes.txt

    回覆刪除
  11. cp -R .../cryptdb/parser/mysql_mods/* mysql-5.5.14/

    i have problem with this..showing no such directory

    回覆刪除
  12. Mel, have a look at the following tutorial: https://m3ideas.org/2017/07/10/infor-grid-on-cryptdb/

    回覆刪除
  13. I was able to set it up and to have the proxy running. As a inital step, I created a simple database via the MySQL shell including a table “names” and some entries, without connecting through the proxy. However, if I connect through the cryptDB proxy, I’m not even able to do a simple “select * from names”, without causing the error:

    “Error: Bad Query: [select * from names]
    Error Data: open_normal_and_derived_tables
    FILE: main/rewrite_main.cc
    LINE: 1380”

    I would be soo grateful if someone could help me out.

    回覆刪除
  14. I was using https://github.com/klevstad/CryptDB_Docker to setup cryptdb in a simple manner.

    回覆刪除