Browse Source

Try calling the new AES functions

Ian Goldberg 2 years ago
parent
commit
1ce26a1f18
2 changed files with 13 additions and 3 deletions
  1. 2 2
      Makefile
  2. 11 1
      rdpf.cpp

+ 2 - 2
Makefile

@@ -1,6 +1,6 @@
 all: prac
 
-CXXFLAGS=-std=c++17 -Wall -ggdb
+CXXFLAGS=-march=native -std=c++17 -Wall -ggdb
 LDFLAGS=-ggdb
 LDLIBS=-lbsd -lboost_system -lboost_context -lboost_chrono -lboost_thread -lpthread
 
@@ -28,4 +28,4 @@ mpcio.o: mpcio.hpp types.hpp
 preproc.o: types.hpp coroutine.hpp mpcio.hpp preproc.hpp rdpf.hpp
 online.o: online.hpp mpcio.hpp types.hpp mpcops.hpp coroutine.hpp
 mpcops.o: mpcops.hpp types.hpp mpcio.hpp coroutine.hpp
-rdpf.o: rdpf.hpp mpcio.hpp types.hpp coroutine.hpp bitutils.hpp
+rdpf.o: rdpf.hpp mpcio.hpp types.hpp coroutine.hpp bitutils.hpp aes.hpp

+ 11 - 1
rdpf.cpp

@@ -2,6 +2,7 @@
 
 #include "rdpf.hpp"
 #include "bitutils.hpp"
+#include "aes.hpp"
 
 // Construct a DPF of the given depth to be used for random-access
 // memory reads and writes.  The DPF is construction collaboratively by
@@ -17,6 +18,15 @@ void rdpf_gen(MPCTIO &tio, yield_t &yield,
     arc4random_buf(&seed, sizeof(seed));
     // Ensure the flag bits (the lsb of each node) are different
     seed = set_lsb(seed, !!player);
-    for(int i=0;i<16;++i) { printf("%02x", ((unsigned char *)&seed)[15-i]); } printf("\n");
+    printf("seed: "); for(int i=0;i<16;++i) { printf("%02x", ((unsigned char *)&seed)[15-i]); } printf("\n");
     rdpf.seed = seed;
+
+    AESkey prgkey;
+    __m128i key = _mm_set_epi64x(314159265, 271828182);
+    AES_128_Key_Expansion(prgkey, key);
+    __m128i left, right;
+    AES_ECB_encrypt(left, set_lsb(seed, 0), prgkey);
+    printf("left: "); for(int i=0;i<16;++i) { printf("%02x", ((unsigned char *)&left)[15-i]); } printf("\n");
+    AES_ECB_encrypt(right, set_lsb(seed, 1), prgkey);
+    printf("rght: "); for(int i=0;i<16;++i) { printf("%02x", ((unsigned char *)&right)[15-i]); } printf("\n");
 }