Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiao1254 committed Jul 30, 2020
1 parent 0f3d9fc commit d707eac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 81 deletions.
6 changes: 3 additions & 3 deletions emp-tool/garble/garble_gate_privacy_free.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static inline void garble_gate_eval_privacy_free(block A, block B,
{
block tmp, mask;

tmp = xorBlocks(double_block(A), tweak);
tmp = xorBlocks(sigma(A), tweak);
mask = tmp;
AES_ecb_encrypt_blks(&tmp, 1, key);
HA = xorBlocks(tmp, mask);
Expand Down Expand Up @@ -55,8 +55,8 @@ static inline void garble_gate_garble_privacy_free(block LA0, block A1,
{
block masks[2], keys[2];

keys[0] = xorBlocks(double_block(LA0), tweak);
keys[1] = xorBlocks(double_block(A1), tweak);
keys[0] = xorBlocks(sigma(LA0), tweak);
keys[1] = xorBlocks(sigma(A1), tweak);
memcpy(masks, keys, sizeof keys);
AES_ecb_encrypt_blks(keys, 2, key);
HLA0 = xorBlocks(keys[0], masks[0]);
Expand Down
4 changes: 0 additions & 4 deletions emp-tool/utils/aes_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@ typedef struct KEY_SCHEDULE
block8=_mm_aesenclast_si128(block8, (*(__m128i const*)(keys[7].KEY+i*16))); \
}

static block sigma(block a) {
return xorBlocks(_mm_shuffle_epi32(a, 78), _mm_and_si128(a, _mm_set_epi64x(0xFFFFFFFFFFFFFFFF, 0x00)));
}

/*
* AES key scheduling for 2/4/8 keys
*/
Expand Down
73 changes: 5 additions & 68 deletions emp-tool/utils/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ inline bool isOne(const block * b) {
return _mm_testz_si128(neq, neq) > 0;
}

__attribute__((target("sse4")))
inline block sigma(block a) {
return xorBlocks(_mm_shuffle_epi32(a, 78), _mm_and_si128(a, _mm_set_epi64x(0xFFFFFFFFFFFFFFFF, 0x00)));
}


//Modified from
//https://mischasan.wordpress.com/2011/10/03/the-full-sse2-bit-matrix-transpose-routine/
Expand Down Expand Up @@ -165,74 +170,6 @@ inline void sse_trans(uint8_t *out, uint8_t const *inp, uint64_t nrows,
const char fix_key[] = "\x61\x7e\x8d\xa2\xa0\x51\x1e\x96"
"\x5e\x41\xc2\x9b\x15\x3f\xc7\x7a";

/*
This file is part of JustGarble.
JustGarble is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
JustGarble is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JustGarble. If not, see <http://www.gnu.org/licenses/>.
*/


/*------------------------------------------------------------------------
/ OCB Version 3 Reference Code (Optimized C) Last modified 08-SEP-2012
/-------------------------------------------------------------------------
/ Copyright (c) 2012 Ted Krovetz.
/
/ Permission to use, copy, modify, and/or distribute this software for any
/ purpose with or without fee is hereby granted, provided that the above
/ copyright notice and this permission notice appear in all copies.
/
/ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
/ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
/ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
/ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
/ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
/ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
/ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/
/ Phillip Rogaway holds patents relevant to OCB. See the following for
/ his patent grant: http://www.cs.ucdavis.edu/~rogaway/ocb/grant.htm
/
/ Special thanks to Keegan McAllister for suggesting several good improvements
/
/ Comments are welcome: Ted Krovetz <ted@krovetz.net> - Dedicated to Laurel K
/------------------------------------------------------------------------- */
__attribute__((target("sse2")))
inline block double_block(block bl) {
const __m128i mask = _mm_set_epi32(135,1,1,1);
__m128i tmp = _mm_srai_epi32(bl, 31);
tmp = _mm_and_si128(tmp, mask);
tmp = _mm_shuffle_epi32(tmp, _MM_SHUFFLE(2,1,0,3));
bl = _mm_slli_epi32(bl, 1);
return _mm_xor_si128(bl,tmp);
}

__attribute__((target("sse2")))
inline block LEFTSHIFT1(block bl) {
const __m128i mask = _mm_set_epi32(0,0, (1<<31),0);
__m128i tmp = _mm_and_si128(bl,mask);
bl = _mm_slli_epi64(bl, 1);
return _mm_xor_si128(bl,tmp);
}
__attribute__((target("sse2")))
inline block RIGHTSHIFT(block bl) {
const __m128i mask = _mm_set_epi32(0,1,0,0);
__m128i tmp = _mm_and_si128(bl,mask);
bl = _mm_slli_epi64(bl, 1);
return _mm_xor_si128(bl,tmp);
}

/**
University of Bristol : Open Access Software Licence
Expand Down
3 changes: 0 additions & 3 deletions emp-tool/utils/ccrh.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class CCRH: public PRP { public:
return xorBlocks(t, in);
}

static block sigma(block a) {
return xorBlocks(_mm_shuffle_epi32(a, 78), _mm_and_si128(a, _mm_set_epi64x(0xFFFFFFFFFFFFFFFF, 0x00)));
}

#ifdef __GNUC__
#ifndef __clang__
Expand Down
6 changes: 3 additions & 3 deletions emp-tool/utils/prp.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PRP { public:
}

block H(block in, uint64_t id) {
in = double_block(in);
in = sigma(in);
__m128i k_128 = _mm_loadl_epi64( (__m128i const *) (&id));
in = xorBlocks(in, k_128);
block t = in;
Expand All @@ -59,7 +59,7 @@ class PRP { public:
void H(block out[n], block in[n], uint64_t id) {
block scratch[n];
for(int i = 0; i < n; ++i) {
out[i] = scratch[i] = xorBlocks(double_block(in[i]), _mm_loadl_epi64( (__m128i const *) (&id)));
out[i] = scratch[i] = xorBlocks(sigma(in[i]), _mm_loadl_epi64( (__m128i const *) (&id)));
++id;
}
permute_block(scratch, n);
Expand All @@ -73,7 +73,7 @@ class PRP { public:
scratch = new block[length];
}
for(int i = 0; i < length; ++i){
out[i] = scratch[i] = xorBlocks(double_block(in[i]), _mm_loadl_epi64( (__m128i const *) (&id)));
out[i] = scratch[i] = xorBlocks(sigma(in[i]), _mm_loadl_epi64( (__m128i const *) (&id)));
++id;
}
permute_block(scratch, length);
Expand Down

0 comments on commit d707eac

Please sign in to comment.